; Disassembly of the file "Z:\home\knoppix\CoBra Project\Software\CPM\CPM SYSGEN 64 chr_line analysis\Boot_Sector.bin"
; 
; CPU Type: Z80
; 
; Using the opcode map file "Z:\home\knoppix\CoBra Project\Software\CPM\CPM SYSGEN 64 chr_line analysis\Boot_Sector.opmap"
; ; Created with dZ80 2.0
; 
; on Tuesday, 24 of January 2017 at 08:48 PM
;

	ORG	$0000

	JR	START

	DEFB	$00
	DEFB	$80
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00

START:	DI	
	LD	HL,$0100
	LD	SP,HL		; set stack at $0100
	LD	A,$92		; control word for 8255: Mode Set flag=active,
				; 			Group A: Select Mode 0,
				;				 Port A set to Input mode,
				;				 Port C (upper half) set to Output Mode,
				;			Group B: Select Mode 0,
				;				 Port B set to Input Mode,
				;				 Port C (lower half) set to Output Mode
	OUT	($DF),A		; write control word to 8255
	OUT	($DF),A		; write control word to 8255 (again !?)
	LD	A,$41
	OUT	($FE),A		; set 06 to "1" for VRAM access, border to blue
	LD	DE,$F600
	LD	BC,$0A00
	LDIR			; copy $0100-$0AFF to $F600-$FFFF	(BIOS)
					; when done, HL=$0B00
	LD	DE,$6E00
	LD	BC,$0600
	LDIR			; copy $0B00-$10FF to $6E00-$73FF	(BLOCK#3, 1536 bytes)
					; when done, HL=$1100
	LD	DE,$6600
	LD	BC,$0800
	LDIR			; copy $1100-$18FF to $6600-$6DFF	(BLOCK#2, 2048 bytes)
					; when done, HL=$1900
	LD	DE,$6300
	LD	BC,$0300
	LDIR			; copy $1900-$1BFF to $6300-$65FF	(BLOCK#1, 768 bytes)
					; when done, HL=$1C00
	LD	DE,$E800
	LD	BC,$0E00
	LDIR			; copy $1C00-$29FF to $E800-$F5FF	(BDOS, 3584 bytes)
					; when done, HL=$2A00
	LD	DE,$7800
	LD	BC,$0800
	LDIR			; copy $2A00-$31FF to $7800-$7FFF	(CCP, 2048 bytes)
					; when done, HL=$3200
					; CCP will be relocated to $E000-$E7FF by BIOS CTC INT. ROUTINE #2 (F8C9)

			; ################### BIOS MODIFICATIONS ######################
	LD	A,$D9		; ----------- BIOS DPH area ------------
	LD	($FB00),A	; change XLT in DPH#0 in BIOS
	LD	($FB10),A	; change XLT in DPH#1 in BIOS
;	LD	($FB40),A	; change XLT in DPH#4 in BIOS
	LD	A,$CA
	LD	($FB0A),A	; change DPB in DPH#0 in BIOS
	LD	($FB1A),A	; change DPB in DPH#1 in BIOS
;	LD	($FB4A),A	; change DPB in DPH#4 in BIOS
;	LD	($F659),A	; change DPB addr stored parameter in BIOS
	LD	HL,$FDA0
	LD	($FB1C),HL	; change CSV in DPH#1 to $FDA0 (for DD it is double the size of SD, so we have to move CSV area somewhere else)
	LD	HL,$FE60
	LD	($FB1E),HL	; change ALV in DPH#1 to $FDC0 (for DD it is double the size of SD, so we have to move CSV area somewhere else)
				; ----------- BIOS SECTRAN fix for A:,B: to be 860K DSDD drives -----------
	LD	HL,$0000
	LD	($F80C),HL	; changes 2804="JR Z,$F812" to NOP NOP
				; ----------- BIOS BLOCK#1 fix for A:,B: to be the same as C:,D: ----------
	LD	($7035),HL	; changes 2808="JR Z,$703F" to NOP NOP
	LD	($6EA9),HL	; changes 2802="JR Z,$6EAD" to NOP NOP
	LD	($70AC),HL	; changes 2805="JR Z,$70B3" to NOP NOP
	LD	A,$18
	LD	($6EC3),A	; changes $20="JR NZ, ..." to "JR ..."
			; #############################################################

;	RES	6,A		; A=$01
	LD	A,$01		; A=$01
	OUT	($FE),A		; set 06 to "0" for DRAM access
	LD	HL,$00FF
	LD	DE,$0100
	LD	BC,$E706
	NOP			; \ deleted
	NOP			; / LDIR ?
	JP	$F600		; jump to start of BIOS (BIOS function #0, BOOT)